<template>
	<view class="page-fade-in" :style="{opacity: pageOpc}">
		<template v-if="pageOpc">
			<view class="content">
				<view class="card-box">
					<view class="card-top">
						<view class="card-name">{{shopName}}</view>
						<view class="card-tip">门店卡</view>
					</view>
					<view class="balance-box flexWrap">
						<view class="money">{{userInfo.wallet||'0.00'}}</view>
						<view class="recharge-btn"  @tap="goPage('/moduleE/balancereCharge')">充值</view>
					</view>
					<view class="service-box flexWrapNo" @tap="makePhoneCall()">
						<view class="service-img">
							<image src="../static/user/wechat.png"></image>
							<image src="../static/user/service.png"></image>
						</view>
						<view class="service-info">
							<view>门店客服8:00-23:00</view>
							<view class="phone">{{phoneNumber}}</view>
						</view>
					</view>
				</view>
				<view class="card-box currency">
					<view class="card-top flexWrap">
						<view>
							<view class="card-name">貘鱼台球</view>
							<view class="card-tip">通卡</view>
						</view>
						<image src="../static/user/logo.png" class="logo"></image>
					</view>
					<view class="balance-box flexWrap">
						<view class="money">{{userInfo.money||'0.00'}}</view>
						<view class="recharge-btn" @tap="goPage('/moduleE/platformRecharge')">充值</view>
					</view>
				</view>
				<view class="function-box flexWrap">
					<view class="function-item flexWrap">
						<view class="function-left">
							<view>会员福利群</view>
							<view class="function-tips">入群享优惠</view>
						</view>
						<image src="../static/user/more-icon.png" class="more-icon"></image>
					</view>
					<view class="function-item flexWrap" @tap="goPage('/moduleE/set')">
						<view class="function-left">
							<view>设置</view>
							<view class="function-tips"  @tap.stop="goPage('/moduleE/editUserInfo')">修改资料</view>
						</view>
						<image src="../static/user/more-icon.png" class="more-icon"></image>
					</view>
				</view>
				<!-- <view class="ad-box">
					<image src="../static/ad.png"></image>
				</view> -->
			</view>
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageOpc:0,
				phoneNumber:"",
				userInfo:{
					wallet:0,
					nickname:'去登录',
					mobile:"",
					avatar:"https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132"
				},
				defaultAvatar:"https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132",
				paymentConfig:{},
				inviteLink:"",
				shopName:""
			}
		},
		onReady(){
			setTimeout(() => {
				this.pageOpc=1
			}, 100)
		},
		onShow() {
			if(uni.getStorageSync('token')){
				this.getUserInfo();
			}
			this.phoneNumber=uni.getStorageSync('customerServiceMobile')
			this.shopName=uni.getStorageSync('shop_name')||""
			this.inviteLink=uni.getStorageSync('crowdCode')
			this.paymentConfig=uni.getStorageSync('paymentConfig')
		},
		onLoad() {
			// uni.setStorageSync('token',"1ef2d067-1635-4ea2-97a6-1da5cecb7843")
			
		},
		methods: {
			goLogin(){
				if(!uni.getStorageSync('token')){
					uni.navigateTo({
						url: "/pages/login/login"
					});
				}
			},
			// 拨打电话
			makePhoneCall() {
				let that = this
				if(!that.phoneNumber){
					this.$tools.showToast('暂无客服电话')
					return;
				}
				uni.makePhoneCall({
					phoneNumber:that.phoneNumber
				})
			},
			// 获取用户信息
			getUserInfo(){
				this.$request.post(this.$api.userInfo, {
					store_id:uni.getStorageSync('store_id')
				}, {
					token:true
				}).then(res => {
					let {
						data = {}
					} = res;
					if (res.code==1) {
						this.userInfo=data
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.content{
		padding:20upx;
	}
	.card-box{
		// height: 354rpx;
		background: linear-gradient( 133deg, #FFFFFF 0%, #F7FFBF 100%);
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		padding: 40upx 32upx;
		margin-bottom: 14upx;
		.card-top{
			.card-name{
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 38rpx;
				color: #232428;
			}
			.card-tip{
				font-weight: 400;
				font-size: 30rpx;
				color: #919190;
				margin-top: 12upx;
			}
		}
		.balance-box{
			margin-top: 40upx;
			.money{
				font-family:cursive;
				font-weight: bold;
				font-size: 100rpx;
				color: #141414;
			}
			.recharge-btn{
				width: 188rpx;
				height: 96rpx;
				line-height: 96rpx;
				text-align: center;
				background: linear-gradient( 93deg, #4AA22A 0%, #69D037 100%);
				border-radius: 72rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 600;
				font-size: 34rpx;
				color: #FFFFFF;
			}
		}
		.service-box{
			margin-top: 24upx;
			.service-img{
				image{
					width: 96upx;
					height: 96upx;
					&:nth-last-of-type(1){
						margin-left: -30upx;
					}
				}
			}
			.service-info{
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 26rpx;
				color: #595A4E;
				margin-left: 12upx;
				.phone{
					font-family: PingFang SC, PingFang SC;
					font-weight: 600;
					font-size: 34rpx;
					color: #141414;
					margin-top: 6upx;
				}
			}
		}
	}
	.currency{
		// height: 244rpx;
		background: linear-gradient( 140deg, #FFFFFF 0%, #C6E0FF 100%);
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		.logo{
			width: 108upx;
			height: 108upx;
		}
		.balance-box{
			margin-top: 50upx;
		}
	}
	.function-box{
		.function-item{
			height: 220rpx;
			width: 286rpx;
			background: #232428;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			padding: 0 32upx;
			align-items: center;
			.function-left{
				font-family: PingFang SC, PingFang SC;
				font-weight: 600;
				font-size: 34rpx;
				color: #FFFFFF;
				.function-tips{
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 26rpx;
					color: #8A8B8D;
					margin-top: 55upx;
				}
			}
			.more-icon{
				width: 72upx;
				height: 72upx;
			}
		}
	}
	.ad-box{
		height: 192upx;
		margin-top: 12upx;
	}
</style>
